<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.blockchain.front.servlets.SendEmailCode"%>
<%@page import="com.blockchain.front.servlets.security.Smrz"%>
<%@page import="com.blockchain.front.service.financial.entity.TxRecordEntity"%>
<%@page import="com.blockchain.common.enums.WithdrawStatus"%>
<%@page import="com.blockchain.front.servlets.security.Bank"%>
<%@page import="com.blockchain.front.service.security.entity.BankCard"%>
<%@page import="com.blockchain.front.service.financial.entity.UserZhEntity"%>
<%@page import="com.blockchain.front.servlets.SendVice"%>
<%@page import="com.blockchain.front.servlets.Send"%>
<%@page import="com.blockchain.front.servlets.security.Qbbz"%>
<%@page import="com.blockchain.front.service.financial.entity.XlbEntity"%>
<%@page import="com.blockchain.util.http.URLParameter"%>
<%@page import="com.blockchain.front.servlets.financial.AbstractFinancialServlet"%>
<%@page import="com.blockchain.front.service.AbstractFrontService"%>
<%@page import="com.blockchain.front.servlets.AbstractFrontServlet"%>
<%@page import="com.blockchain.front.service.financial.entity.JlEntity"%>
<%@page import="com.blockchain.common.enums.JyztStatus"%>
<%@page import="com.blockchain.front.service.security.entity.QbdzEntity"%>
<%@page import="com.blockchain.front.service.security.SecurityManage"%>
<%@page import="com.blockchain.front.service.financial.FinancialManage"%>
<html>
<head>
<%
String str = languageDefine.getValue(request, "eurWithdraw_eurWithdraw");
String _TITLE_ = str + "- "+configureProvider.getProperty(SystemVariable.SITE_NAME);
CURRENT_SUB_CATEGORY="RMBTX";
PC_TITLE_NAME="RMBTX";
URLParameter parameter = new URLParameter(request,controller.getViewURI(request,CnyTx.class));
SecurityManage securityManage = serviceSession.getService(SecurityManage.class);
int dzid=IntegerParser.parse(request.getParameter("dzid"));
WithdrawStatus zt=EnumParser.parse(WithdrawStatus.class, request.getParameter("zt"));
FinancialManage fmanage=serviceSession.getService(FinancialManage.class);
UserManage usanage=serviceSession.getService(UserManage.class);
FinancialManage manage=serviceSession.getService(FinancialManage.class);
final int currentPage = IntegerParser.parse(request.getParameter("paging.current"));
UserZhEntity z=fmanage.getCny();
BankCard[] bs=securityManage.bankList();
 PagingResult<TxRecordEntity> searchTxjl=manage.searchTxjl(dzid,zt,new Paging() {
	public int getCurrentPage() {
		return currentPage;
	}

	public int getSize() {
		return 5;
	}
});
 TxRecordEntity[] search=searchTxjl.getItems(); //列表  
 User us=usanage.getUser();
 BigDecimal fv=BigDecimalParser.parse(configureProvider.getProperty(SystemVariable.WITHDRAW_FV));
 BigDecimal max=BigDecimalParser.parse(configureProvider.getProperty(SystemVariable.WITHDRAW_MAX_FUNDS));
 BigDecimal min=BigDecimalParser.parse(configureProvider.getProperty(SystemVariable.WITHDRAW_MIN_FUNDS));
 BigDecimal mrxe=BigDecimalParser.parse(configureProvider.getProperty(SystemVariable.WIDTHDRAW_PER_LIMIT));
 BigDecimal min_sxf = new BigDecimal(configureProvider.getProperty(SystemVariable.WITHDRAW_MIN_SXF));
%> 
<title><%=_TITLE_ %></title>
<%@include file="/WEB-INF/include/meta.jsp"%>
<%@include file="/WEB-INF/include/style.jsp"%>
<%@include file="/WEB-INF/include/authenticatedSession.jsp"%>
</head>
<%@include file="/WEB-INF/include/header.jsp"%>
<div class="autobox">
 <div class="now">
  <a href="<%=controller.getViewURI(request, com.blockchain.front.servlets.Index.class)%>" class="orange"><%=languageDefine.getValue(request, "menu_home")%></a> &gt; <a href="<%=controller.getViewURI(request,com.blockchain.front.servlets.financial.index.class)%>" class="orange"><%=languageDefine.getValue(request, "menu_financeCenter")%> </a> &gt; <%=languageDefine.getValue(request, "eurWithdraw_eurWithdraw")%>
 </div>
 	<div class="assets_center clear po_re zin70">
  <%@include file="/WEB-INF/include/financial/left.jsp"%>	
   <div class="assets_content w900 right bg_w">
        <div class="safe_center clear" style="padding-left: 0px;">
            <h1 style="margin-top: 0px; margin-bottom: 15px; line-height: 15px;"><%=languageDefine.getValue(request, "eurWithdraw_eurWithdraw")%></h1>
        </div>
        <div class="mytips">
            <h6 style="color: #ff8000;">温馨提示</h6>
            <p style="font-size:14px;">
                <span style="color:#E53333;">1、限额：单笔最低提现金额<%=Formater.formatAmount(min)%>UDSZ，单笔最高提现金额<%=Formater.formatAmount(max)%>UDSZ；<br>
                2、费率：目前，提现手续费率为<%=Formater.formatAmount(fv.multiply(new BigDecimal(100)))%>%，单笔最低手续费为<%=Formater.formatAmount(min_sxf)%>UDSZ；<br>
                3、提现到账时间：正常情况下1个工作日到账，最多不超过3个工作日，节假日顺延；<br>
               <!--  4、若未按时到账，请联系QQ客服：3093283991处理。 -->
            </span>
            </p>
        </div>
        <form action="<%=controller.getURI(request, CnyTx.class)%>" method="post" id="form" >
        <input type="hidden" name="phone" value="<%=us.iphone%>">
            <div class="choosepaymethod">
                <div class="choosebanks" style="margin-top: 10px;">
                    <div class="methodway clearfix">
                        <div class="w_div clearfix">
                            <div class="w1"><%=languageDefine.getValue(request, "withdrawals_available")%>：</div>
                            <div class="w2" style="color: #333;">                                
                                <span><font class="coin-balance" style="color: #690!important;"><%=Formater.formatAmount(z.cny_ky)%></font></span>
                            </div>
                        </div>
                        <div class="w_div clearfix">
                            <div class="w1"><%=languageDefine.getValue(request, "rmbWithdraw_withdrawAmount")%>：</div>
                            <div class="w2">
                                <input name="txje" type="text" class="cztxinput" id="num" onkeyup="keyUpToDo(this)" maxlength="10" style="border-radius: 8px;">
                       
                                ≈ <em style="color:#EA6647;" id="toRate">0.00</em> CNY
                            </div>
                        </div>
                        <div class="w_div clearfix">
                            <div class="w1"><%=languageDefine.getValue(request, "rmbWithdraw_withdrawAddress")%>：</div>
                            <div class="w2" id="temp_addr">
                            <%if(bs!=null){%>
                           	 <select name="dzid" id="mytx_type" style="width: 200px; height: 38px;border-radius: 8px;" onchange="todoChange(this)">
                                 <option value="tianjia">----<%=languageDefine.getValue(request, "rmbWithdraw_addOneAddress")%>----</option>
                                  <%
                                  StringBuilder sb = new StringBuilder("[");
                                  for(BankCard b:bs  ){ 
                                	  sb.append("{\"id\":"+b.id+",\"phoneNumber\":\""+(null==b.phoneNumber?"":b.phoneNumber)+"\"},");
                                  %>
                                 <option <%if(b.id==dzid){%> selected="selected"<%}%> value="<%=b.id%> ">
                                 <%StringHelper.filterHTML(out,b.yh);%>(<%StringHelper.filterHTML(out, b.kh.substring(0,4)+"****"+b.kh.substring(b.kh.length()-3));%>)
                                 </option>
                                 <%}
                                  String tempStr = sb.toString();
	                              if(tempStr.endsWith(",")) tempStr = tempStr.substring(0,tempStr.length()-1);
	                              tempStr+="]";
                                 %>
                                  </select>
                                  <div id="allBankCard" style="display:none"><%=tempStr%></div>
                                 <%}else{%>
                                  <a href="<%=controller.getViewURI(request,Bank.class)%>" style="line-height: 36px;color:#0d66bf;"><%=languageDefine.getValue(request, "rmbWithdraw_addOneAddress")%></a>
                                 <%}%>
                            </div>
                        </div>
                        <div class="w_div clearfix">
                        	<div class="w1"><%=languageDefine.getValue(request, "withdrawals_phone")%>：</div>
                            <div class="w2"><input type="text" name="phoneNumber" id="phoneNumber" class="cztxinput" style="border-radius: 8px;"></div>
                        </div>
                        <div class="w_div clearfix">
                            <div class="w1"><%=languageDefine.getValue(request, "rmbWithdraw_smsVerificationCode")%>：</div>
                            <div class="w2">
                                <input type="text" name="txlbverifyCode" class="cztxinput" id="moble_verify" value="" style="width: 70px;border-radius: 8px;">
                            <input id="regBtn" type="button" class="getyzm" value='<%=languageDefine.getValue(request, "rmbWithdraw_getFreeVerificationCode")%>' onclick="SendCode(this);" style="width: 108px;height: 35px;" maxlength="4"> 
                                 <span style="color:#EA6647;"><%=languageDefine.getValue(request, "rmbWithdraw_receiveSmsPhone")%><%StringHelper.truncationMpno(out, us.iphone);%></span>
                            </div>
                        </div>
                        <div class="w_div clearfix">
                            <div class="w1"><%=languageDefine.getValue(request, "rmbWithdraw_tradePassword")%>：</div>
                            <div class="w2">
                                <input type="password"  class="cztxinput" id="paypassword" name="tjmx" autocomplete="off" style="border-radius: 8px;">
                            </div>
                        </div>
                        <div class="w_div clearfix">
                            <div class="w1">&nbsp;</div>
                            <div class="w2">
                                <input type="button" class="btn-cztx"  onclick="Update()" value='<%=languageDefine.getValue(request, "rmbWithdraw_submit")%>' title='<%=languageDefine.getValue(request, "rmbWithdraw_submit")%>' style="border-radius: 8px;">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="f_body">
                    <table class="f_table" id="investLog_content">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th><%=languageDefine.getValue(request, "rmbWithdraw_withdrawTime")%></th>
                            <th><%=languageDefine.getValue(request, "rmbWithdraw_withdrawAmount")%></th>
                            <th><%=languageDefine.getValue(request, "rmbWithdraw_fee")%></th>
                            <th><%=languageDefine.getValue(request, "withdrawals_actualAmount")%></th>
                            <th><%=languageDefine.getValue(request, "rmbWithdraw_arrivalMoney")%></th>
                            <th><%=languageDefine.getValue(request, "rmbWithdraw_withdrawAddress")%></th>
                            <th width="">
                                <select name="zt" id="status-selectTest">
                                    <option value=""><%=languageDefine.getValue(request, "rmbWithdraw_status")%></option>
                                    <%for(WithdrawStatus w:WithdrawStatus.values()){%>
                 					<option  <%if(w.name().equals(String.valueOf(zt))){%> selected="selected"<%}%> value="<%=w.name()%>"><%=backgroundDataFlag==1?w.getName():backgroundDataFlag==2?w.getNameEn():w.getNameTw()%></option>
                 					<%}%>
                                </select>
                            </th>
                        </tr>
                        </thead>
                        <tbody>
               <%if(search!=null){for(TxRecordEntity s:search){%> 
            	<tr>
            	<td><%=s.id%></td>
                <td><%=TimestampParser.format(s.sqsj)%></td>
                <td><%=Formater.formatAmount(s.txje.add(s.fy))%></td>
                <td><%=Formater.formatAmount(s.fy)%></td>
                <td><%=Formater.formatAmount(s.txje)%></td>
                <td><%=Formater.formatAmount(s.cny)%></td>
                <td><%StringHelper.filterHTML(out,s.yhkh);%></td>
                <td><%=s.type.getName()%></td>
            </tr>
            <%}}%>
                        </tbody>
                    </table>
                     <%AbstractFinancialServlet.rendPaging(out, searchTxjl,controller.getPagingURI(request,CnyTx.class),parameter.getQueryString());%>
                </div>
            </div>
            </form>
        </div>
        
 </div>
</div>

<%@include file="/WEB-INF/include/footer.jsp"%>
<%@include file="/WEB-INF/include/script.jsp"%>
<script type="text/javascript">
var eur_ky=<%=z.cny_ky%>;
$(function(){
	<%-- <%if(StringHelper.isEmpty(us.name)||StringHelper.isEmpty(us.zjh)){%>	
	layer.open({  
	         content: '<%=languageDefine.getValue(request, "js_notVerified")%>',  
	         btn: ['<%=languageDefine.getValue(request, "js_confirm")%>'],  
	         yes: function(index, layero) {  
	         window.location.href='<%=controller.getViewURI(request, Smrz.class)%>';  
	         },  
	        cancel: function() {  
	       	window.location.href='<%=controller.getViewURI(request, Smrz.class)%>';  
	         }  
	     }); 
	<%}%>
	
	<%if(!usanage.gjsmrz()){%>	
	layer.open({  
	         content: '<%=languageDefine.getValue(request, "js_notSuperVerified")%>',  
	         btn: ['<%=languageDefine.getValue(request, "js_confirm")%>'],  
	         yes: function(index, layero) {  
	         window.location.href='<%=controller.getViewURI(request, Smrz.class)%>';  
	         },  
	        cancel: function() {  
	       	window.location.href='<%=controller.getViewURI(request, Smrz.class)%>';  
	         }  
	     }); 
	<%}%> --%>
	});

var _cUrl = '<%=controller.getURI(request, SendEmailCode.class)%>';
var wait = 60;
var phone="<%=us.iphone%>";
var min =<%=min%>; 
var max =<%=max%>; 
var fv=<%=fv%>; 

$("#mytx_type").change(function () {
	        var type = $("#mytx_type option:selected").val();
	        if (type == 'tianjia') {
	            window.location = '<%=controller.getViewURI(request, Bank.class)%>';
		}
	});
$("#status-selectTest").change(function () {
	$("#form").attr("action",'<%=controller.getViewURI(request, CnyTx.class)%>');	
	$("#form").submit();
});
function Update() {
	        var addr = $('#mytx_type option:selected').val();
	        var addr = $('#mytx_type option:selected').val();
	        if(undefined==addr){
	        	layer.tips('<%=languageDefine.getValue(request, "js_chooseAddress")%>', '#temp_addr', {tips: 3});
	            return false;
	        }
	        var num = $("#num").val();
	        var phoneNumber=$("#phoneNumber").val();
	        var moble_verify = $("#moble_verify").val();
	        var paypassword = $("#paypassword").val();
	        if (addr == "" || addr == null||addr=='tianjia') {
	            layer.tips('<%=languageDefine.getValue(request, "js_chooseAddress")%>', '#mytx_type', {tips: 3});
	            return false;
	        }
	        if (num == "" || num == null) {
	            layer.tips('<%=languageDefine.getValue(request, "js_withdrawAmount")%>', '#num', {tips: 3});
	            return false;
	        }
	        if(num<min){
	        	layer.tips('<%=languageDefine.getValue(request, "js_withdrawAmountLessThanMin")%>'+min+'', '#num', {tips: 3});
	            return false;
	        }
	        if(num>max){
	        	layer.tips('<%=languageDefine.getValue(request, "js_withdrawAmountLessThanMax")%>'+max+'', '#num', {tips: 3});
	            return false;
	        }
	        if(num>eur_ky){
	        	layer.tips('<%=languageDefine.getValue(request, "err_1035")%>'+eur_ky+'', '#num', {tips: 3});
	            return false;
	        }
	        
	        if(phoneNumber=="" || phoneNumber==null){
	        	 layer.tips('<%=languageDefine.getValue(request, "withdrawals_phone")%>', '#phoneNumber', {tips: 3});
		         return false;
	        }

	        if (moble_verify == "" || moble_verify == null) {
	            layer.tips('<%=languageDefine.getValue(request, "js_smsVerificationCode")%>', '#moble_verify', {tips: 3});
	            return false;
	        }

	        if (paypassword == "" || paypassword == null) {
	            layer.tips('<%=languageDefine.getValue(request, "js_tradePassword")%>', '#paypassword', {tips: 3});
	            return false;
	        }
	        
	        $("#form").submit();  
	    }
	
	function SendCode(evn){
		sendclick(evn);
		var data={"type":"CNYTX","phone":phone};
		  $.ajax({
			type:"post",
			dataType:"html",
			url:_cUrl,
			data:data,
			success:function(data){
				var ct = eval('('+data+')');
					if(ct[0].num == 2){
						
					}else{
					layer.tips(ct[0].msg.indexOf("err_")!=-1?eval("_error_global."+ct[0].msg):ct[0].msg, '#moble_verify', {tips: 2});
					return false;
					}
				}
		});   
	}
	 function sendclick(evn){
		 var obj = $('#regBtn');
		 if (wait == 0) {
				obj.val('<%=languageDefine.getValue(request, "js_getCaptcha")%>');
	            obj.css('background','#0d66bf');
	            obj.removeAttr("disabled");
				wait = 60;
			} else {
				$('#regBtn').css('background','#999B9C');
				$('#regBtn').val(wait + '<%=languageDefine.getValue(request, "js_sendAgain")%>');
	             wait--;
				  setTimeout(function() {
					sendclick(evn);
				},1000); 
			}
		}	
	
<%String error = controller.getPrompt(request,response,PromptLevel.ERROR);if(!StringHelper.isEmpty(error)){%>
	layer.open({
	title: '<%=languageDefine.getValue(request, "js_tip")%>',
	content: '<%=languageDefine.getValue(request, error)%>'
});  
<%}%>
<%String info = controller.getPrompt(request,response,PromptLevel.INFO);if(!StringHelper.isEmpty(info)){%>
layer.open({
title: '<%=languageDefine.getValue(request, "js_tip")%>',
content: '<%=info%>'
});  
<%}%>

function keyUpToDo(obj){
	var value=obj.value.replace(/[^0-9.]/g,'');
	obj.value=value;
	value=value.replace(/\.\d{6,}$/,value.substr(value.indexOf('.'),7));
	$("#toRate").text(accMul(value,<%=configureProvider.get("SYSTEM.EUR_CNY_RATE")%>));
}
/**
 * 精确计算两个浮点数相乘 
 */
function accMul(arg1,arg2) {  
    var m=0,s1=arg1.toString(),s2=arg2.toString();  
    try{m+=s1.split(".")[1].length}catch(e){}  
    try{m+=s2.split(".")[1].length}catch(e){}  
    return keep2DecimalPoint((Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)).toFixed(3));
}
function keep2DecimalPoint(v){
	return v.substring(0,v.toString().length - 1);
}

/**
 * 选择银行卡时处理
 */
 function todoChange(obj){
	var v = obj.value;
	if(v!=""){
		var allBankCard = $("#allBankCard").text();
		var bcs = JSON.parse(allBankCard);
		for(var i=0;i<bcs.length;i++){
			if(bcs[i].id==v){
				$("#phoneNumber").val(bcs[i].phoneNumber);
				break;
			}
		}
	}
}
</script>
</body>
</html>	
	
